package fun._6742.exception;

import org.springframework.http.HttpStatus;

public class CustomException extends RuntimeException {

    private static final long serialVersionUID = 1L;
    public static final int DEFAULT_CODE = -1;

    private int code = DEFAULT_CODE;

    public CustomException() {
        super();
    }

    public CustomException(int code, String message) {
        super(message);
        this.setCode(code);
    }
    public CustomException(HttpStatus httpStatus) {
        super(httpStatus.getReasonPhrase());
        this.setCode(httpStatus.value());
    }

    public CustomException(HttpStatus httpStatus, String extraMsg) {
        super(httpStatus.getReasonPhrase()+": "+extraMsg);
        this.setCode(httpStatus.value());
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }
}
